/**
 * 项目名称: Topic_563.cpp
 * 项目路径: study/DataStructure/LeetCode/树/简单
 * 编辑时间: 2024年08月10日08时16分27秒
 * 用   户: 轻尘
 */

#include <bits/stdc++.h>

using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;

    TreeNode() : val(0), left(nullptr), right(nullptr) {}

    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

class Solution {
public:
    int ans =0;
    int OnOrder(TreeNode* root){
        int left = 0;
        int right = 0;

        if(root->left){
            left += OnOrder(root->left);
        }

        if(root->right){
            right += OnOrder(root->right);
        }
        ans += abs(left-right);
        return left+right+root->val;
    }
    int findTilt(TreeNode* root) {
        if(!root)return 0;
        OnOrder(root);
        return ans;
    }
};

int main() {

    return 0;
}
